package com.bg.order.controller;

import com.bg.order.entity.Order;
import com.bg.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.client.RestTemplate;

import java.math.BigDecimal;
import java.util.UUID;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author bg
 * @since 2023-02-09
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @RequestMapping("/add")
    public void add(String userId, String commodityCode, Integer count, BigDecimal amount) {
        Order order = new Order();
        order.setOrderNo(UUID.randomUUID().toString());
        order.setUserId(userId);
        order.setAmount(amount);
        order.setCommodityCode(commodityCode);
        order.setCount(count);
        orderService.save(order);
    }

}
